import { initGlobalState } from 'qiankun';

// 不能嵌套 否则无法修改
const state = {
  token: 'dsfdafewfw-dsafdsaf',
  userName: 'chris',
  other: {
    info: '11111'
  }
}

// 初始化 state
const actions = initGlobalState(state);

actions.onGlobalStateChange((state, prev) => {
  // state: 变更后的状态; prev 变更前的状态
  console.log(state, prev);
});

actions.getGlobalState = () => {
  return state
}

export default actions